﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ReAnimation.MVP.ViewInterfaces;
using ReAnimation.MVP.Presenters;
using ReAnimation.Helpers.Common;
using ReAnimation.Helpers.WinForms;

namespace ReAnimation.MVP.Views
{//TODO: it's almost copy&paste of new molecule dialog view... should be merged.
    public partial class NewAnimationDialog : BaseFormView,INewAnimationDialogView
    {
        private NewAnimationDialogPresenter _presenter;
        public NewAnimationDialog(NewAnimationDialogPresenter presenter)
        {
            presenter.View = this;
            InitializeComponent();
        }

        #region INewAnimationDialogView Members

        public event EventHandler Cancel;

        public event EventHandler<EventArg<string>> Create;

        public void ShowViewDialog()
        {
            ShowDialog();
        }

        #endregion

        private void NewAnimationDialog_FormClosed(object sender, FormClosedEventArgs e)
        {
            Cancel.Throw(sender, e);
        }

        private void newMoleculeButton_Click(object sender, EventArgs e)
        {
            Create.Throw(sender, new EventArg<string>(animationNameTextBox.Text));
        }

        private void animationNameTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                newMoleculeButton_Click(this, EventArgs.Empty);
        }
    }
}
